const set = new Set()

onconnect = (event) => {
	const port = event.ports[0]
	set.add(port)

	// 接收消息
	port.onmessage = (e) => {
		// 广播消息
		set.forEach((p) => {
			if (p === port) return
			p.postMessage(e.data)
		})
	}

	// 发送消息
	port.postMessage('work.js ok')
}
